# Python 绝对路径和相对路径详解
import os
print(os.getcwd())

os.chdir("/home/yangjun/git")
print(os.getcwd())

#os.chdir("/home/yangjun/error") # FileNotFoundError: [Errno 2] No such file or directory: '/home/yangjun/error'

print(os.path.abspath("."))

print(os.path.abspath("./python_base"))

print(os.path.isabs("."))

print(os.path.abspath("."))

print(os.path.relpath("/home/yangjun/git", "/home"))

print(os.path.relpath("/home/yangjun/git", "/opt/lib"))

path = "/home/yangjun/git/python_base/pb12_file_operation/absolute_relative_path.py"
print(os.path.basename(path))

print(os.path.dirname(path))

print(os.path.split(path))

print(os.path.exists(path))

print(os.path.isfile(path))

print(os.path.isdir(path))
